<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">采购合同确认</h4>
</div>
<style>
    .form-copy {
        width: 200px;
        margin-right: 5px;
        border-radius: 0;
        box-shadow: none;
        padding: 4px 12px 7px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        border: 1px solid #ccc;
        transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    }
</style>
<form id="pur_contract-form" action="/xqc/purchase/order-ajax" method="post">
    <div class="box box-solid no-margin box-show">
        <div class="box-body">
            @include('purchase.contract-confirm.header')
            @include('purchase.contract-confirm.sku')
            @include('purchase.contract-confirm.protocol')
            @include('purchase.contract-confirm.footer')
        </div>
    </div>
    <div class="modal-footer">
        {{ csrf_field() }}
        <input type="hidden" name="action" value="createPurContract">
        <input type="hidden" name="param[id]" value="{{ $id }}">
        <input type="hidden" name="param[purchase_no]" value="{{ $purchase->purchase_no }}">
        <select id="file_type" name="param[file_type]">
            <option value="1" selected>PDF</option>
            <option value="2">Excel</option>
        </select>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary create-file"><span id="loading">确定</span></button>
    </div>
</form>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('#file_type').select2({placeholder: '格式',minimumResultsForSearch: -1, width: '70px'});
        $("#pur_contract-form").ajaxForm(
            {
                dataType: 'json',
                beforeSend: function(){
                    $('#loading').text('生成中');
                    $('.create-file').attr('disabled',true);
                },
                success: function (data) {
                    $('#loading').text('确定');
                    $('.create-file').removeAttr('disabled');
                    $("#purContractModal").modal('hide');
                    $(".modal-backdrop").remove();
                    $('body').removeClass('modal-open');
                    if (typeof data === 'object') {
                        if (data.status) {
                            toastr.success(data.message);
                            $.pjax.reload('#order-edit-form');
                        } else {
                            swal(data.message, '', 'error');
                        }
                    }
                }
            }
        );
    });
</script>
